#pragma once
#include <utility>
#include <map>
#include "Xps/Manager/IManager.h"

namespace Xps
{
    class Manager :
        public IManager
    {
    public:
        typedef std::map<std::string, IProtocol::Ptr> ProtocolMap;
        typedef std::pair<std::string, IProtocol::Ptr> ProtocolMapPair;
        typedef std::map<std::string, IProtocol::Ptr>::iterator ProtocolMapIterator;
        typedef std::map<std::string, IProtocol::Ptr>::const_iterator ProtocolMapConstIterator;

        typedef std::map<std::string, ITask::Ptr> TaskMap;
        typedef std::pair<std::string, ITask::Ptr> TaskMapPair;
        typedef std::map<std::string, ITask::Ptr>::iterator TaskMapIterator;
        typedef std::map<std::string, ITask::Ptr>::const_iterator TaskMapConstIterator;

        static IManager * getInstance();

        virtual bool RegisterProtocol( const std::string &_ProtocolName, IProtocol::Ptr _Protocol );

        virtual bool UnRegisterProtocol( const std::string &_ProtocolName );

        virtual bool RegisterTask( const std::string &_TaskName, ITask::Ptr _Task );

        virtual bool UnRegisterTask( const std::string &_TaskName );

        virtual bool PushPacket( const std::string &_ProtocolName, const IPacket::Ptr _Packet );

        virtual void Start();

        virtual void Stop();

        virtual IProtocol::Ptr getProtocol(const std::string &_ProtocolName);

        virtual ~Manager(void);

    private:
        Manager(void);

        ProtocolMap protocol_map;
        TaskMap task_map;

    };

};
